home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 November
/
EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso
/
earcd
/
misc
/
nnn.lha
/
nnn1.35
/
src
/
NetVecRand.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-20
|
1KB
|
64 lines
/*
* $Id: NetVecRand.c 1.3 1995/03/14 23:11:41 daltern Exp $
*
* Function NetVecRand
* Programmer Nicholas d'Alterio
* Date 15/01/95
*
* Synopsis: This randomises the order of a set of vectors by
* swapping random rows many times.
*
* $Log: NetVecRand.c $
* Revision 1.3 1995/03/14 23:11:41 daltern
* Added comments and cleaned up
*
*
*/
#include "Neural.h"
void NetVecRand( VECTOR *vec )
{
register int i;
int row1;
int row2;
float *temp_in_row;
float *temp_out_row;
/*
* Randomise data sets by swapping 2 random rows NUM_RAND_STEPS times.
*/
for ( i = 0; i < NUM_RAND_STEPS; i++ ) {
/*
* Get 2 random rows to swap.
*/
row1 = (int)((vec->NumVecs-1) * RAND_FUNC());
row2 = (int)((vec->NumVecs-1) * RAND_FUNC());
/*
* Swap rows over.
*/
temp_in_row = vec->InVec[row1];
temp_out_row = vec->OutVec[row1];
vec->InVec[row1] = vec->InVec[row2];
vec->OutVec[row1] = vec->OutVec[row2];
vec->InVec[row2] = temp_in_row;
vec->OutVec[row2] = temp_out_row;
} /* end for i */
return;
} /* end function NetVecRand */